<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags"%>


<html>
<head>
<title>Files list</title>
<script type="text/javascript">
  function formatLink(cellvalue, options, rowObject) {
		//var path= rowObject.filePath + rowObject.fileName;
		var fileId = rowObject.fileId;
	        //return "<a href="+path+" onClick='javascript:openDialog("+cellvalue+")'>" + cellvalue + "</a>";
		return '<a href="View3DFile.action?fileId=' + fileId + '">' + cellvalue + '</a>';
}
        
</script>

<sj:head jqueryui="true" jquerytheme="redmond" />
</head>

<body>
	<div id="functionLabel">
		<p>CAD FILE MANAGEMENT SYSTEM BY RITATSU SOFT</p>
	</div>
	
	<div id="insForm">
		<s:form action="viewAllFileAction" method="post" theme="simple">
			<table>
				<tr>
					<td><s:label key="label.filename"></s:label></td>
					<td><s:textfield cssClass="searchbox" name="query" size="60" /></td>
				</tr>
				<tr>
					<td colspan="2" width="50%" align="center"><s:submit method="execute" cssClass="button" key="label.search"/></td>
				</tr>
			</table>
		</s:form>
	</div>
	
	<div id="extra">
		<s:a cssClass="button-link" action="Add">Upload file</s:a>		
	</div>
	<s:url var="remoteurl" action="getjson" />
	<s:url var="editurl" action="editfile" />
	<div id="grid">
		<sjg:grid
			cssClass="gridcontent"
			gridModel="listFiles"
			id="gridtable"
			caption="Cad file management"
			pager="true"
			href="%{remoteurl}"
			editurl="%{editurl}" 
			width="980"
			rowList="10,15,20" 
			rowNum="15"
			dataType="json"
			rownumbers="true"
			multiselect="true"
			cellEdit="false"
			viewrecords="true"
			viewsortcols="[true, 'horizontal', true]"
			navigator="true"
			editinline="false"
			navigatorAdd="false"
			navigatorEdit="true"
			
			navigatorEditOptions="{
    			reloadAfterSubmit:true,
    			closeAfterEdit:true
    			}"
			navigatorDelete="true"
			navigatorDeleteOptions="{
    			reloadAfterSubmit:true
    			}"
			navigatorExtraButtons="false"
			navigatorView="true"
			navigatorInlineEditButtons="false"
			>
			
			<sjg:gridColumn 
				name="fileId"
				index="fileId"
				key="true"
				title="ID"
				width="50"
    			search="true"
    			sortable="true"
    			editable="true"
    			hidden="true"
    			searchoptions="{sopt:['eq','ne','lt','gt']}">
			</sjg:gridColumn>
		
			<sjg:gridColumn 
				name="fileName" 
				index="fileName" 
				title="File Name"
				sortable="false" 
				searchoptions="{sopt:['eq']}" 			
				formatter="formatLink"	
				editable="false"
				search="true"
    			edittype="text"/>
 
    		<sjg:gridColumn 
				name="user.username" 
				index="user.username" 
				title="Upload by"
				width="80"
				sortable="false" 
				searchoptions="{sopt:['eq']}" 
				editable="false"
				search="true"
    			edittype="text"/>
    			
			<sjg:gridColumn 
				name="filePath" 
				index="filePath" 
				title="File Path"
				sortable="false"
				search="false"
				editable="false" />
				
			<sjg:gridColumn 
				name="fileType" 
				index="fileType"
				width="100"
				title="Extension"
				sortable="false"
				search="true"
				searchoptions="{sopt:['eq']}"
				editable="false" />
			<sjg:gridColumn
				width="80" 
				name="fileSize"
				index="fileSize"
				title="Size"
				sortable="false"
				search="false"
				editable="false" />
			<sjg:gridColumn 
				name="fileUploadDate"
				index="fileUploadDate"
				title="Upload Date"
				sortable="false"
				search="false"
				formatter="date" 
				formatoptions="{newformat : 'd.m.Y H:i', srcformat : 'Y-m-d H:i:s'}"
				editable="false"/>
			<sjg:gridColumn 
				name="downloadTime" 
				index="downloadTime"
				title="Downs"
				align="center"
				sortable="false"
				width="50"
				search="false"
				editable="false"/>
			<sjg:gridColumn
				name="thumbnailPath"
				index="thumbnailPath"
				title="Thumbnail path"
				sortable="false"
				search="false" 
				editable="true"
				edittype="text"/>
			<sjg:gridColumn 
				name="filePublic"
				index="filePublic"
				title="is public"
				sortable="false" 
				editable="true"
				search="true"
				edittype="checkbox"/>		
		</sjg:grid>
	 </div>

</body>
</html>